﻿Public Class ConsoleAnswers

    Private Const cErrorCode As Integer = 1

    Public Shared Sub WriteErrorMessageAndEndApplication(ByVal aMessage As String, ByVal anErrorCode As Integer)
        WriteErrorMessage(aMessage:=aMessage)
        Console.WriteLine()
        Console.Write("Press any key to close the application")
        Console.ReadKey()
        System.Environment.Exit(anErrorCode)
        End
    End Sub
    Public Shared Sub WriteErrorMessageAndEndApplication(ByVal aMessage As String)
        WriteErrorMessageAndEndApplication(aMessage:=aMessage, anErrorCode:=cErrorCode)
    End Sub

    Public Shared Sub WriteMessage(ByVal aMessage As String)
        Console.BackgroundColor = ConsoleColor.Black
        Console.ForegroundColor = ConsoleColor.White
        Console.WriteLine(aMessage)
    End Sub

    Public Shared Sub WriteErrorMessage(ByVal aMessage As String)
        Console.BackgroundColor = ConsoleColor.White
        Console.ForegroundColor = ConsoleColor.Red
        Console.WriteLine(aMessage)
    End Sub

    Public Shared Function GetText(ByVal aMessage As String) As String
        Console.WriteLine(aMessage)
        Dim myAnswer As String = Console.ReadLine()
        Return myAnswer
    End Function

End Class
